using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;


namespace App3._3
{
    /// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>

    public partial class Window1 : System.Windows.Window
    {
        public Window1()
        {
            InitializeComponent();
        }

        void Collected(object sender, InkCanvasStrokeCollectedEventArgs args)
        {
            canvas.Children.Clear();
            Brush brush = new SolidColorBrush(Colors.Blue);
            StylusPointCollection points = args.Stroke.StylusPoints;

            if (points.Count == 0)
                return;

            StylusPoint prePoint = points[0];
            foreach (StylusPoint point in points)
            {
                if (args.Stroke.StylusPoints.IndexOf(point) == 0)
                    continue;

                double radius = (point.X - prePoint.X) * (point.X - prePoint.X)
                + (point.Y - prePoint.Y) * (point.Y - prePoint.Y);
                radius = Math.Sqrt(radius) * 2;

                Ellipse mark = new Ellipse();
                Canvas.SetLeft(mark, point.X - radius / 2);
                Canvas.SetTop(mark, point.Y - radius / 2);
                mark.Opacity = 0.5;
                mark.Width = mark.Height = radius;
                mark.Fill = brush;
                canvas.Children.Add(mark);

                prePoint = point;
            }
        }
    }
}